const jwt = require('jsonwebtoken')
const SECRET = 'ewgfvwergvwsgw5454gsrgvsvsd'
const auth = async (ctx,res,next) => {
    console.log(ctx.headers)
    const {token = ''} = ctx.headers
    const tk = token.replace('Bearer ',"")
        const user = jwt.verify(tk,SECRET)
        ctx.id=user.id
        next()
}
module.exports=auth